package com.shu.auth.controller;

import com.shu.auth.common.ApplicationContextHelper;
import com.shu.auth.common.JsonData;
import com.shu.auth.dao.SysAclModuleMapper;
import com.shu.auth.exception.BaseException;
import com.shu.auth.model.SysAclModule;
import com.shu.auth.utils.BeanValidator;
import com.shu.auth.utils.JsonMapper;
import com.shu.auth.vo.TestVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@Slf4j
public class TestController {
    @RequestMapping("/test")
    public JsonData test(){
        log.info("hello spring mvc");
        throw  new RuntimeException("测试异常");
//        return JsonData.success("hello spring mvc");
    }
    @RequestMapping("/validate.json")
    public JsonData validate(TestVo vo){
        log.info("validate");

        //BeanValidator.check(vo);
        SysAclModuleMapper moduleMapper = ApplicationContextHelper.popBean(SysAclModuleMapper.class);
        SysAclModule sysAclModule = moduleMapper.selectByPrimaryKey(1);
        log.info(JsonMapper.obj2String(sysAclModule));
        return JsonData.success("校验测试");
    }
}
